$(function () {
    $(".l .Q2 i").click(function () {
        $(this).addClass("on");
        setTimeout(function () {
            $(".l .Q2 em").addClass("on");
        }, 1000);
        setTimeout(function(){
            $(".l .Q2 em").removeClass("on");
        }, 3500);
    });
    function show() {
       $(".l .Q2 i").removeClass("on");
    }
    setInterval(show, 3000);
});

$(function () {
    $(".r .Q3 i").click(function () {
        $(this).addClass("on");
        setTimeout(function () {
            $(".r .Q3 em").addClass("on");
        }, 1000);
        setTimeout(function () {
            $(".r .Q3 em").removeClass("on");
        }, 3500);
    });
    function show() {
       $(".r .Q3 i").removeClass("on");
    }
    setInterval(show, 3000);
});

function GetRefresh(str) {
    var $labels = $("#" + str).find("label"),
        i, len = $labels.length,
        lblIds = [], lblKeys = [], lblItems = [],
        lblData, keyword = '';

    for (i = 0; i < len; i++) {
        if (lblData = $labels[i].getAttribute("lbldata")) {
            lblData = lblData.split("|");
            lblIds.push($labels[i].id);
            lblKeys.push(lblData[0]);
            lblItems.push(lblData[1]);
        }
    }
    if (len = lblIds.length) {
        keyword += lblKeys.join("|");
        if (lblKeys[0].indexOf("/") > 0) {
            refreshEx(keyword, lblKeys, lblIds, lblItems);
        } else {
            refreshNSEx(keyword, lblKeys, lblIds, lblItems);
        }
    }
}

function refreshEx(keyword, keys, ids, cols) {
    var requrl = '/ICBCDynamicSite/services/GetExchangeInfoN.ashx?keyword_objID=' + encodeURIComponent(keyword);
    $.ajax({
        url: requrl,
        dataType: "json",
        success: function (data) {
            var i, len;
            var dic = {}, unitData;
            var value;
            if (data.pub.retCode === '0' && data.pvt && data.pvt.length) {
                var i, len;
                var dic = {}, unitData;
                for (i = 0, len = data.pvt.length; i < len; i++) {
                    if (data.pvt[i]) dic[data.pvt[i].cur1 + '/' + data.pvt[i].cur2] = data.pvt[i];
                }
                ids = ids || [];
                for (i = 0, len = ids.length; i < len; i++) {
                    unitData = dic[keys[i]] || {};
                    value = unitData[cols[i]] || '-';
                    if (unitData) document.getElementById(ids[i]).innerHTML = value;
                }
            }
        },
        error: function (err) {
        }
    });
}

function refreshNSEx(keyword, keys, ids, cols) {
    var requrl = '/ICBCDynamicSite/services/GetNSExchangeInfoN.ashx?keyword_objID=' + encodeURIComponent(keyword);
    $.ajax({
        url: requrl,
        dataType: "json",
        success: function (data) {
            var i, len;
            var dic = {}, unitData;
            var value;
            if (data.pub.retCode === '0' && data.pvt && data.pvt.length) {
                var i, len;
                var dic = {}, unitData;
                for (i = 0, len = data.pvt.length; i < len; i++) {
                    if (data.pvt[i]) dic[data.pvt[i].curtype] = data.pvt[i];
                }
                ids = ids || [];
                for (i = 0, len = ids.length; i < len; i++) {
                    unitData = dic[keys[i]] || {};
                    value = unitData[cols[i]] || '-';
                    if (unitData) document.getElementById(ids[i]).innerHTML = value;
                }
            }
        },
        error: function (err) {
        }
    });
}
